<?php

namespace app\models;

use yii;
use app\components\BaseActiveRecord;

/**
 * This is the model class for table "{{%like}}".
 *
 * @property integer $id
 * @property integer $uid
 * @property integer $own
 * @property integer $own_id
 * @property integer $ctime
 */
class Like extends BaseActiveRecord {

    const OWN_COMMENT = 1;
    const OWN_POST = 2;
    const OWN_ACTIVITY = 3;

    /**
     * @inheritdoc
     */
    public static function tableName() {
        return '{{%like}}';
    }

    /**
     * @inheritdoc
     */
    public function rules() {
        return [
            [['uid', 'own', 'own_id', 'ctime'], 'integer']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'uid' => 'Uid',
            'own' => 'Own',
            'own_id' => 'Own ID',
            'ctime' => 'Ctime',
        ];
    }

    public static function getIsLike($own, $own_id, $uid) {
        return static::find()->where(['own' => $own, 'own_id' => $own_id, 'uid' => $uid])->count() > 0;
    }
}
